package com.alks.function.controller.subcontract;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.entity.dispatch.UserOemRelation;
import com.alks.entity.data.entity.imes.Brand;
import com.alks.entity.data.entity.imes.BrandOemRelation;
import com.alks.entity.data.entity.imes.SysUserSub;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.service.subcontract.SubcontractService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * @author:hxl
 * @create: 2024-12-17 14:20
 * @Description:
 */
@ApiRestController("/subcontract/config")
@Api(tags = "工厂配置")
public class SubcontractConfigController {
    @Autowired
    private SubcontractService subcontractService;


    @PostMapping({"/user/list"})
    @WebLogger
    @ApiOperation(value = "用户列表",tags = "工厂配置")
    public ResponseInfo list(@RequestBody SysUserSub user) {
        return subcontractService.selectUserByRoleId(user);
    }

    @PostMapping({"/user/ome"})
    @WebLogger
    @ApiOperation(value = "工厂列表",tags = "工厂配置")
    public ResponseInfo list(@RequestParam  Long userId) {
        return subcontractService.selectByUserId(userId);
    }

    @PostMapping({"/user/ome/add"})
    @WebLogger
    @ApiOperation(value = "工厂添加",tags = "工厂配置")
    public ResponseInfo add(@RequestBody UserOemRelation userOemRelation) {
        return subcontractService.add(userOemRelation);
    }

    @PostMapping({"/user/ome/delete"})
    @WebLogger
    @ApiOperation(value = "工厂删除",tags = "工厂配置")
    public ResponseInfo delete(@RequestBody UserOemRelation userOemRelation) {
        return subcontractService.deleteVendor(userOemRelation);
    }

    @PostMapping({"/brand/ome"})
    @WebLogger
    @ApiOperation(value = "品牌",tags = "工厂配置")
    public ResponseInfo brandOemRelationslist(@RequestParam @ApiParam("用户id") Long userId) {
        return subcontractService.brandOemRelationslist(userId);
    }

    @PostMapping({"/brand/ome/add"})
    @WebLogger
    @ApiOperation(value = "品牌添加",tags = "工厂配置")
    public ResponseInfo addBrand(@RequestBody BrandOemRelation userOemRelation) {
        return subcontractService.addBrand(userOemRelation);
    }

    @PostMapping({"/brand/ome/delete"})
    @WebLogger
    @ApiOperation(value = "品牌删除",tags = "工厂配置")
    public ResponseInfo deleteBrand(@RequestBody BrandOemRelation userOemRelation) {
        return subcontractService.deleteBrand(userOemRelation);
    }

    @PostMapping({"/combo"})
    @WebLogger
    @ApiOperation(value = "品牌回显",tags = "工厂配置")
    public ResponseInfo oemCombo() {
        return subcontractService.brandComboList();
    }

    @PostMapping({"/queryBrandList"})
    @WebLogger
    @ApiOperation(value = "品牌列表",tags = "工厂配置")
    public ResponseInfo queryBrandList(@RequestBody Brand brand) {
        return subcontractService.queryBrandList(brand);
    }

    @PostMapping({"/insertBrand"})
    @WebLogger
    @ApiOperation(value = "品牌列表品牌添加",tags = "工厂配置")
    public ResponseInfo insertBrand(@RequestBody Brand brand) {
        return subcontractService.insertBrand(brand);
    }

    @PostMapping({"/deleteBrands"})
    @WebLogger
    @ApiOperation(value = "品牌列表品牌删除",tags = "工厂配置")
    public ResponseInfo deleteBrands(@RequestBody Brand brand) {
        return subcontractService.deleteBrands(brand);
    }
}
